package com.demo2do.fms.entity.supplier.trans;

import org.apache.commons.lang3.StringUtils;

import com.demo2do.core.utils.Alias;

/**
 * 运输的服务供方  车辆信息 挂车类型
 * 
 * Created by zhonghui on 2017/7/13.
 */
@Alias("SupplierTrailerType")
public enum TrailerType {

    TRAILER_TYPE_ZERO("one","open","开放式"),

    TRAILER_TYPE_ONE("one","half-closed","左右封闭式"),

    TRAILER_TYPE_TWO("one","closed","全封闭"),
    
    TRAILER_TYPE_THREE("Two","plat-form","平板车"),

    TRAILER_TYPE_FOUR("Two","flying-car","飞翼车"),
    
    TRAILER_TYPE_FIVE("Two","old-column","高栏车"),

    TRAILER_TYPE_SIX("Two","low-column","低栏车");
    
    private String code;
    
    private String alias;
    
    private String description;

    /**
     * @param code
     * @param alias
     * @param description
     */
    private TrailerType(String code , String alias , String description) {
        this.code = code;
        this.alias = alias;
        this.description = description;
    }
    
    /**
     * 
     * @param code
     * @return
     */
    public static TrailerType codeOf(String code) {

        for (TrailerType trailerType : TrailerType.values()) {
            if (trailerType.getCode().equals(code)) {
                return trailerType;
            }
        }
        
        return null;
    }
    
    /**
     * 
     * @param alias
     * @return
     */
    public static TrailerType aliasOf(String alias) {

        for (TrailerType trailerType : TrailerType.values()) {
            if (trailerType.getAlias().equals(alias)) {
                return trailerType;
            }
        }

        return null;

    }
   
    /**
     * @return
     */
    public boolean isOne() {
        return StringUtils.equalsIgnoreCase("one", this.code);
    }

    /**
     * 
     * @return
     */
    public String getCode() {
        return code;
    }
    
    /**
     * 
     * @return
     */
    public String getAlias() {
        return alias;
    }
    
    /**
     * Gets description.
     *
     * @return the description
     */
    public String getDescription() {
        return description;
    }
    
}